package animation.sort.algorithms;

import animation.core.AlgorithmMonitorModel;

/**
 * Created by IntelliJ IDEA.
 * User: emilio
 * Date: Aug 19, 2004
 * Time: 12:09:13 PM
 * To change this template use File | Settings | File Templates.
 */
public class BottomUpMerge
        extends MergeSort
{
    public String toString()
    {
        return "Bottom-Up MergeSort";
    }

    void sort(int array[], int low, int high)
            throws Exception
    {
        for (int middle = 1; middle <= high-low; middle *= 2) {
            final int middleX2 = middle*2;
            for (int low1 = low; low1 <= high-middle; low1 += middleX2) {
                final int high1 = Math.min(low1 - low + middleX2 - 1, high);
                merge(array, low1, low1+middle-1, high1);
            }
        }
    }

    protected void registerSpecificVariables(AlgorithmMonitorModel monitorModel) {
        //todo IMPLEMENT!
    }
}
